import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// import Components from 'unplugin-vue-components/vite';
// import { VantResolver } from 'unplugin-vue-components/resolvers';
import postCssPxToRem from "postcss-pxtorem"

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    // Components({
    //   resolvers: [VantResolver()]
    // })
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src') // 路径别名
    },
    extensions: ['.ts', '.vue', '.js', '.jsx', '.tsx'] // 导入时想要省略的扩展名列表。

  },
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 37.5, // 1rem的大小
          propList: ['*'], // 需要转换的属性，这里选择全部都进行转换
        })
      ]
    }
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://sph-h5-api.atguigu.cn',
        changeOrigin: true,
        rewrite(path) {
          return path.replace(/^\/api/, '')
        }
      },
      '/wyyx': {
        target: 'https://m.you.163.com',
        changeOrigin: true,
        rewrite(path) {
          return path.replace(/^\/wyyx/, '')
        }
      }
    }
  }
})
